package com.joey.concurrency.example.singleton;

import com.joey.concurrency.annotation.NotThreadSafe;
import com.joey.concurrency.annotation.ThreadSafe;
import lombok.extern.slf4j.Slf4j;

/**
 * 饿汉模式
 * 单例实例在类装载使用时创建
 * @Author hyy
 **/
@ThreadSafe
public class SingtonExample2 {

    private SingtonExample2(){
        //不能有太多处理，并且资源最好不被浪费
    }

    private static SingtonExample2 instance = new SingtonExample2();

    public static SingtonExample2 getInstance(){
        return instance;
    }
}
